package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.utils.Result;
import com.ruoyi.common.utils.ResumeUtil;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysUserResume;
import com.ruoyi.system.service.ISysUserResumeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 简历拆分测试Controller
 * 
 * @author TYF
 * @date 2022-10-29
 */
@Controller
@RequestMapping("/system/resume")
public class SysUserResumeController extends BaseController
{
    private String prefix = "system/resume";

    @Autowired
    private ISysUserResumeService sysUserResumeService;

    @RequiresPermissions("system:resume:view")
    @GetMapping()
    public String resume()
    {
        return prefix + "/resume";
    }

    /**
     * 查询简历拆分测试列表
     */
    @RequiresPermissions("system:resume:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(String userId,SysUserResume sysUserResume)
    {
        startPage();
        sysUserResume.setSid(userId);
        List<SysUserResume> list = sysUserResumeService.selectSysUserResumeList(sysUserResume);
        return getDataTable(list);
    }

    /**
     * 导出简历拆分测试列表
     */
    @RequiresPermissions("system:resume:export")
    @Log(title = "简历拆分测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysUserResume sysUserResume)
    {
        List<SysUserResume> list = sysUserResumeService.selectSysUserResumeList(sysUserResume);
        ExcelUtil<SysUserResume> util = new ExcelUtil<SysUserResume>(SysUserResume.class);
        return util.exportExcel(list, "简历拆分测试数据");
    }

    /**
     * 新增简历拆分测试
     */
    @GetMapping("/add")
    public String add(Model model)
    {
        Long userId = ShiroUtils.getUserId();
        model.addAttribute("userId",userId);
        return prefix + "/add";
    }

    /**
     * 新增保存简历拆分测试
     */
    @RequiresPermissions("system:resume:add")
    @Log(title = "简历拆分测试", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysUserResume sysUserResume)
    {
        return AjaxResult.success();
    }

    /**
     * 简历拆分
     */
    @PostMapping("/formtFwb")
    @ResponseBody
    public AjaxResult formtFwb(String a1701)
    {

        Result result = sysUserResumeService.resolvingA1701(a1701, ShiroUtils.getUserId().toString(), "");

        return AjaxResult.success(result);
    }


    /**
     * 简历描述获取
     */
    @PostMapping("/getJianLiData")
    @ResponseBody
    public AjaxResult getJianLiData(String sid) throws Exception
    {


        return sysUserResumeService.getJianlidata(sid);
    }


    /**
     * 修改简历拆分测试
     */
    @RequiresPermissions("system:resume:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        SysUserResume sysUserResume = sysUserResumeService.selectSysUserResumeById(id);
        mmap.put("sysUserResume", sysUserResume);
        return prefix + "/edit";
    }

    /**
     * 修改保存简历拆分测试
     */
    @RequiresPermissions("system:resume:edit")
    @Log(title = "简历拆分测试", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysUserResume sysUserResume)
    {
        return toAjax(sysUserResumeService.updateSysUserResume(sysUserResume));
    }

    /**
     * 删除简历拆分测试
     */
    @RequiresPermissions("system:resume:remove")
    @Log(title = "简历拆分测试", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysUserResumeService.deleteSysUserResumeByIds(ids));
    }
}
